<template>
	<view class="wrapper">
		<view class="top">
			<u-navbar
				title="邀请好友"
				leftIconColor="#fff"
				leftIconSize="40rpx"
				:titleStyle="navbarTitleStyle"
				:bgColor="navbarBgColor"
				:placeholder="true"
				:fixed="true"
				autoBack
			></u-navbar>
			<image class="top-bg" src="@/package-purse/static/images/invitationBg.png" mode=""></image>
		</view>
		<view class="process">
			<view class="process-title">邀请流程</view>
			<view class="process-list">
				<view class="process-list-item">
					<image class="process-list-item-icon" src="@/package-purse/static/images/fenxiang.png" mode=""></image>
					<view class="process-list-item-name">发送好友邀请</view>
				</view>
				<image class="process-list-item-xiayibu" src="@/package-purse/static/images/xiayibu.png" mode=""></image>
				<view class="process-list-item">
					<image class="process-list-item-icon" src="@/package-purse/static/images/haoyou.png" mode=""></image>
					<view class="process-list-item-name">好友完成注册 并交易</view>
				</view>
				<image class="process-list-item-xiayibu" src="@/package-purse/static/images/xiayibu.png" mode=""></image>
				<view class="process-list-item">
					<image class="process-list-item-icon" src="@/package-purse/static/images/yongjin.png" mode=""></image>
					<view class="process-list-item-name">获得相应比例 返佣收益</view>
				</view>
			</view>
			<image class="process-btn" src="/package-purse/static/images/lijiyaoqing.png" mode=""></image>
		</view>
		<view class="box">
			<view class="box-item" @click="jumpPage">
				<image class="box-img" src="/package-purse/static/images/tuiguang.png" mode=""></image>
				<view class="box-item-title">推广管理</view>
				<view class="box-item-look">
					去查看
					<image class="box-item-look-icon" src="@/package-purse/static/images/you.png" mode=""></image>
				</view>
			</view>
			<view class="box-item" @click="commissionOpen">
				<image class="box-img" src="/package-purse/static/images/yongjinshuoming.png" mode=""></image>
				<view class="box-item-title">佣金说明</view>
				<view class="box-item-look" style="background: #ffc64c">
					去查看
					<image class="box-item-look-icon" src="@/package-purse/static/images/you.png" mode=""></image>
				</view>
			</view>
		</view>
		<view class="footer">
			<view class="footer-title">团长收益</view>
			<view class="footer-box">
				<view class="footer-box-item">
					{{ info.friend_commission }}
					<view class="footer-box-item-name">累计收益(元)</view>
				</view>
				<view class="footer-box-line"></view>
				<view class="footer-box-item">
					{{ info.friend_total }}
					<view class="footer-box-item-name">我的团员</view>
				</view>
			</view>
		</view>
		<u-popup :show="commissionShow" mode="bottom" bgColor="#fff" @close="commissionClose">
			<view class="commission">
				<view class="commission-top">
					<u-icon class="commission-close" @click="commissionClose" name="close" color="#999999" size="45rpx"></u-icon>
					<view class="commission-top-title">
						佣金说明
						<view class="commission-top-title-line"></view>
					</view>
				</view>
				<view class="commission-main">
					<view class="commission-main-title">
						<text>亲爱的用户，邀请好友一起租手机，轻松赚佣金啦！\n具体规则如下：</text>
					</view>
					<view class="commission-main-text">1. 邀请方式：通过你的专属邀请链接/二维码，邀请好友成功在托管经营里面商品下单</view>
					<view class="commission-main-text">
						<text>2. 佣金计算：好友每下单一台机器，你可获得50元的佣金 \n（例如：好友投资1台，你可赚50元。好友投资5台，你可赚250元。）。</text>
					</view>
					<view class="commission-main-text">
						<text>3. 到账时间：好友下单后，佣金将自动发放至你的账户余额，\n可随时提现。</text>
					</view>
					<view class="commission-main-text">4. 注意事项：需确保好友通过你的专属链接/二维码下单，否则无法计入邀请奖励。</view>
					<view class="commission-main-footer">赶紧邀请身边有投资需求的朋友，一起解锁轻松赚钱的机会吧！</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
import { promotion } from '@/api';
export default {
	data() {
		return {
			info: {
				friend_total: 0, //总推广人数
				friend_commission: 0 //总奖励
			},
			commissionShow: false,
			navbarBgColor: '#FC6A43',
			navbarTitleStyle: {
				fontFamily: 'PingFang SC',
				// fontWeight: 'bold',
				fontSize: '34rpx',
				color: '#fff'
			}
		};
	},
	onLoad() {
		this.getCommissionWallet();
	},
	methods: {
		jumpPage() {
			uni.navigateTo({
				url: '/package-purse/promotion/promotion'
			});
		},
		// 获取推广信息
		async getCommissionWallet() {
			const res = await promotion.promotionInfo();
			this.info = res.data;
		},
		commissionOpen() {
			this.commissionShow = true;
		},
		commissionClose() {
			this.commissionShow = false;
			// console.log('close');
		}
	}
};
</script>

<style lang="scss" scoped>
.wrapper {
	padding-bottom: 60rpx;
}
.top {
	height: 700rpx;
	position: relative;
	&-bg {
		width: 100%;
		height: 100%;
		position: absolute;
		top: 0;
		left: 0;
		z-index: -1;
	}
}
.process {
	padding: 30rpx 20rpx 50rpx;
	background: #ffffff;
	border-radius: 10rpx;
	margin: -120rpx 30rpx 100rpx;
	&-title {
		font-family: 'PingFang SC';
		font-weight: bold;
		font-size: 30rpx;
		color: #333333;
	}
	&-list {
		margin: 40rpx 0 80rpx 0;
		display: flex;
		align-items: center;
		justify-content: space-around;
		padding: 0 40rpx;
		&-item {
			height: 120rpx;
			&-icon {
				margin: 0 auto;
				width: 76.2rpx;
				height: 76.2rpx;
			}
			&-name {
				margin-top: 20rpx;
				text-align: center;
				font-family: 'PingFang SC';
				font-weight: 400;
				font-size: 24rpx;
				color: #333333;
				max-width: 150rpx;
			}
			&-xiayibu {
				width: 58rpx;
				height: 40rpx;
				padding-bottom: 40rpx;
			}
		}
	}
	&-btn {
		width: 600rpx;
		height: 78rpx;
		margin: 0 auto;
	}
}
.box {
	height: 216rpx;
	background: #ffffff;
	border-radius: 10rpx;
	margin: 0 30rpx;
	position: relative;
	display: flex;
	justify-content: space-between;
	padding: 0 30rpx;

	&-img {
		width: 300.4rpx;
		height: 236rpx;
	}
	&-item {
		position: relative;
		top: -50rpx;
		&-title {
			position: absolute;
			font-family: 'PingFang SC';
			font-weight: bold;
			font-size: 30rpx;
			color: #ffffff;
			bottom: 40rpx;
			left: 30rpx;
		}
		&-look {
			position: absolute;
			bottom: -5rpx;
			left: 30rpx;
			font-family: 'PingFang SC';
			font-weight: 400;
			font-size: 22rpx;
			color: #ffffff;
			display: flex;
			align-items: center;
			justify-content: center;
			width: 112rpx;
			height: 39rpx;
			background: #ff3762;
			border-radius: 20rpx;
			opacity: 0.8;
			&-icon {
				width: 20rpx;
				height: 20rpx;
			}
		}
	}
}
.footer {
	width: 690rpx;
	height: 250rpx;
	background: #ffffff;
	border-radius: 10rpx;
	margin: 40rpx 30rpx 0;
	padding: 30rpx 20rpx;
	box-sizing: border-box;
	&-title {
		font-family: 'PingFang SC';
		font-weight: bold;
		font-size: 30rpx;
		color: #333333;
		margin-bottom: 40rpx;
	}
	&-box {
		display: flex;
		align-items: center;
		justify-content: center;
		&-line {
			width: 3rpx;
			height: 80rpx;
			background: #999999;
			opacity: 0.2;
		}
		&-item {
			width: 50%;
			text-align: center;
			font-family: 'PingFang SC';
			font-weight: 500;
			font-size: 48rpx;
			color: #333333;
			box-sizing: border-box;
			&-name {
				font-family: 'PingFang SC';
				font-weight: 400;
				font-size: 24rpx;
				color: #999999;
			}
		}
	}
}
.commission {
	height: 803rpx;
	border-radius: 40rpx 40rpx 0 0;
	position: relative;
	&-top {
		height: 165rpx;
		border-radius: 40rpx 40rpx 0 0;
		background: linear-gradient(0deg, rgba(255, 255, 255, 0.7), /* 白色带 70% 透明度 */ rgba(255, 180, 159, 0.7) /* 粉色带 70% 透明度 */);
		&-title {
			padding-top: 60rpx;
			font-family: ' DFPFangYuanW7-GB';
			font-weight: 400;
			font-size: 36rpx;
			color: #333333;
			text-align: center;
			&-line {
				width: 40rpx;
				height: 6rpx;
				background: #333333;
				border-radius: 3rpx;
				margin: 20rpx auto 0;
			}
		}
	}
	::v-deep .u-icon {
		position: absolute;
		top: 30rpx;
		right: 30rpx;
	}
	&-main {
		padding: 0rpx 35rpx 0;
		&-title {
			font-family: 'PingFang SC';
			font-weight: 500;
			font-size: 28rpx;
			color: #333333;
		}
		&-text {
			margin-top: 35rpx;
			font-family: 'PingFang SC';
			font-weight: 400;
			font-size: 24rpx;
			color: #666666;
		}
		&-footer {
			text-align: center;
			font-family: 'PingFang SC';
			font-weight: 500;
			font-size: 24rpx;
			color: #333333;
			margin-top: 40rpx;
		}
	}
}
::v-deep .u-popup__content {
	border-radius: 40rpx 40rpx 0 0;
}
</style>
